/**
 * @namespace
 */
$.aws.observer = {
	/**
	 * 
	 * @param {Object} eventName Name of event to subscribe execCode to
	 * @param {Object} execName Identificator of function represented by execCode
	 * @param {Object} execCode Function to be executed when eventName happens
	 */
	subscribe: function(eventName, execName, execCode) {
		$.aws.observer.subscribers[eventName] = $.aws.observer.subscribers[eventName] || {};
		$.aws.observer.subscribers[eventName][execName] = execCode;
	},
	/**
	 * 
	 * @param {Object} eventName Name of event to unsubscribe from
	 * @param {Object} execName Identificator of subscribed function
	 */
	unsubscribe: function(eventName, execName) {
		delete $.aws.observer.subscribers[eventName][execName];
	},
	/**
	 * 
	 * @param {Object} eventName Name of event to notify subscribers of
	 * @param {Array} [args] Arguments to be passed to subscribed function
	 * @param {Object} [scope] Scope in which subscribed function should be executed
	 */
	notify: function(eventName, args, scope) {
		if ($.aws.observer.subscribers[eventName]) {
			$.each($.aws.observer.subscribers[eventName], function(k, v) {
				v.apply(scope || window, args || []);
			});
		}
	},
	/**
	 * Holds list of all events and subscribed functions
	 */
	subscribers: {}
};
